home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 2010 April
/
PCWorld0410.iso
/
pluginy Firefox
/
1035
/
1035.xpi
/
chrome
/
1clickweather.jar
/
content
/
1clickweather
/
js
/
utils
/
xul.js
< prev
Wrap
Text File
|
2008-10-05
|
6KB
|
244 lines
// ⌐ 2005 The Weather Channel Interactive, Inc. All Rights Reserved.
// handy xul handlers
// oXULSimple just does basic handling of common xul widgets
// if you need more complex attributes for a widget, see oXUL below
function oXULSimple(){
this.setCLass = function(_parent, c){
_parent.setAttribute("class", c);
}
this.Spacer = function(_parent, size){
var pSpacer = document.createElement("spacer");
pSpacer.setAttribute("flex", 1);
pSpacer.setAttribute("width", size);
pSpacer.setAttribute("height", size);
pSpacer.setAttribute("style", "width: " + size + "; height: " + size + ";");
_parent.appendChild(pSpacer);
}
this.Separator = function(_parent){
var pSeparator = document.createElement("separator");
pSeparator.setAttribute("flex", 1);
_parent.appendChild(pSeparator);
}
this.Image = function(_parent, src, width, height){
var pImage = document.createElement("image");
if(src.substring(0,9) == "chrome://"){
pImage.setAttribute("src", src);
}else{
pImage.setAttribute("src", "chrome://1clickweather/skin/" + src);
}
pImage.setAttribute("width", width);
pImage.setAttribute("height", height);
pImage.setAttribute("style", "font-size: 10pt");
_parent.appendChild(pImage);
}
this.Label = function(_parent, contents, bold){
var pLabel = document.createElement("label");
pLabel.setAttribute("value", contents);
pLabel.setAttribute("class", "panelText");
_parent.appendChild(pLabel);
}
this.Shim = function(_parent, width, height, c){
var pImage = document.createElement("image");
pImage.setAttribute("src", "chrome://1clickweather/skin/icons/other/blank.gif");
pImage.setAttribute("width", width);
pImage.setAttribute("height", height);
if(c){
pImage.setAttribute("class", c);
}
_parent.appendChild(pImage);
}
}
//////////////////////////////////////////////////////////////////////////
// here is a wierd but cool way of doing a grouping of object definitions
//////////////////////////////////////////////////////////////////////////
var oXUL = Array();
// a complex image xul object
oXUL.Image = function(_parent, src){
this._parent = _parent;
var pImage = document.createElement("image");
if(src.substring(0,9) == "chrome://"){
pImage.setAttribute("src", src);
}else{
pImage.setAttribute("src", "chrome://1clickweather/skin/" + src);
}
pImage.setAttribute("style", "font-size: 10pt");
this.setAttribute = function(key, value){
pImage.setAttribute(key, value);
}
this.Size = function(width, height){
pImage.setAttribute("width", width);
pImage.setAttribute("height", height);
}
this.Context = function(context){
pImage.setAttribute("context", context);
}
this.Align = function(dir){
if(!dir)
dir = "center";
pImage.setAttribute("align", dir);
}
this.Id = function(id){
pImage.setAttribute("id", this.id);
}
this.onDblClick = function(cmd){
pImage.setAttribute("ondblclick", cmd);
}
this.onClick = function(cmd){
pImage.setAttribute("onclick", cmd);
}
this.onCommand = function(cmd){
pImage.setAttribute("oncommand", cmd);
}
this.Tooltip = function(tooltip){
if(typeof(tooltip) == "string"){
pImage.setAttribute("tooltiptext", tooltip);
}else{
pImage.setAttribute("tooltip", tooltip);
}
}
this.Make = function(){
this._parent.appendChild(pImage);
}
}
// a complex label xul object
oXUL.Label = function(_parent, value){
this._parent = _parent;
var pLabel = document.createElement("label");
pLabel.setAttribute("class", "panelText");
if(value){
pLabel.setAttribute("value", value);
}
this.setAttribute = function(key, value){
pLabel.setAttribute(key, value);
}
this.setClass = function(c){
pLabel.setAttribute("class", c);
}
this.Context = function(context){
pLabel.setAttribute("context", context);
}
this.Align = function(dir){
if(!dir)
dir = "center";
pLabel.setAttribute("align", dir);
}
this.Id = function(id){
pLabel.setAttribute("id", id);
}
this.Value = function(value){
pLabel.setAttribute("value", value);
}
this.Bold = function(){
pLabel.setAttribute("class", "header");
}
this.Color = function(color){
pLabel.setAttribute("style", "color: " + color);
}
this.Size = function(size){
pLabel.setAttribute("style", "font-size: " + size + "pt");
}
this.onDblClick = function(cmd){
pLabel.setAttribute("ondblclick", cmd);
}
this.onClick = function(cmd){
pLabel.setAttribute("onclick", cmd);
}
this.onCommand = function(cmd){
pLabel.setAttribute("oncommand", cmd);
}
this.Tooltip = function(tooltip){
if(typeof(tooltip) == "string"){
pLabel.setAttribute("tooltiptext", tooltip);
}else{
pLabel.setAttribute("tooltip", tooltip);
}
}
this.Make = function(){
this._parent.appendChild(pLabel);
}
}
// a complex image xul object
oXUL.iconByID = function(_parent, iconID){
this._parent = _parent;
var pImage = document.createElement("image");
pImage.setAttribute("src", GlobalAppConfig.getIconByID(iconID).getURL());
pImage.setAttribute("width", GlobalAppConfig.getIconByID(iconID).getWidth());
pImage.setAttribute("height", GlobalAppConfig.getIconByID(iconID).getHeight());
this.setAttribute = function(key, value){
pImage.setAttribute(key, value);
}
this.Context = function(context){
pImage.setAttribute("context", context);
}
this.Id = function(id){
pImage.setAttribute("id", this.id);
}
this.onDblClick = function(cmd){
pImage.setAttribute("ondblclick", cmd);
}
this.onClick = function(cmd){
pImage.setAttribute("onclick", cmd);
}
this.onCommand = function(cmd){
pImage.setAttribute("oncommand", cmd);
}
this.Tooltip = function(tooltip){
if(typeof(tooltip) == "string"){
pImage.setAttribute("tooltiptext", tooltip);
}else{
pImage.setAttribute("tooltip", tooltip);
}
}
this.Make = function(){
this._parent.appendChild(pImage);
}
}